<?php echo $this->Form->create('Paginate', array('id' => 'paginate', 'url' => $this->request->here(false), 'type' => 'post', 'inputDefaults' => array('label' => false))); ?>	
            <div id="content-header">
				<h1>Menu Link Management</h1>
			</div>
            <div id="breadcrumb">
            	<a href="<?php echo $this->Html->url('/admin/')?>" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
                	<a href="#" class="current">List Menu Link</a>
            </div>
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
                                <?php
            echo $this->element('toolbar');
            ?>	
								
						<div class="widget-box">
							<div class="widget-title">
								<span class="icon">
									<i class="icon-pencil"></i>
								</span>
								<h5>List of pages</h5>
							</div>
							<div class="widget-content widget-content-three">
								<table class="table table-bordered table-striped wd-hover-btn">
									<thead>
										<tr>
                                            <th> <?php echo  __d('system', 'Page name'); ?></th>
                                            <th>  <?php echo  __d('system', 'Parent'); ?></th>
                                            <th class="wd-fix-width-1">  <?php echo  __d('system', 'Translate'); ?></th>                     
											<th class="wd-fix-width-3"> <?php echo  __d('system', 'Action'); ?></th>
										</tr>
									</thead>
									<tbody>
                            <?php
                        
                            $defaultLanguage = Router::defaultLanguage();
                          $_queries = array('continue' => $this->request->here(false));
                            ?>                    
                                  <?php foreach ($listMenuLinks as $menu) : ?>
										<tr>
                                         <?php if(empty($menu['MenuLink']['parent_id'])){?>
					                        <?php if (isset($_displayFields['title'])): ?>       
  	                                           <td>
                                       <strong>  <?php echo $menu['MenuLink']['title']; ?></strong>
                                            </td>
                                         <?php endif; ?>
                                        <?php }else {?>
                                    
					                        <?php if (isset($_displayFields['title'])): ?>       
  	                                           <td>
                                      <span class="wd-asideleft"><?php echo $menu['MenuLink']['title']; ?></span>
                                            </td>   
                                            <?php endif; ?>      
                                        <?php }?>
                                    <?php if(!empty($menu['MenuLink']['parent_id'])){?>
                                    <?php 
                                    $parent_menus= ClassRegistry::init('Menu.MenuLink')->find('first', array(
                                            'locale'=>true,
                                            'conditions' => array('MenuLink.id'=>$menu['MenuLink']['parent_id'],'enabled'=>1),
                                            'order' => array('lft' => 'ASC'),
                                            'fields' => array('id','title', 'path'),
                                            'contain'=> false
                                            )
                                        );
                                    ?>
                                <td><?php echo $parent_menus['MenuLink']['title']?></td>
                                     <?php }else {?>	
								
					                        <?php if (isset($_displayFields['title'])): ?>       
  	                                           <td>
                                         <?php echo $menu['MenuLink']['title']; ?>
                                            </td>
                                         <?php endif; ?>
                                     <?php }?>	
                                     								
            							<td>
                                        <?php if (isset($_translateMaps)): ?>
            									<ul class="wd-laguage">
                                                <?php
                                                    foreach (Configure::read('Languages') as $_language) {
                                                        if ($_language['code'] === $defaultLanguage) {
                                                            continue;
                                                    } ?>
                                                    <?php 
                                                        if(empty($_language['path'])){
                                                            $flags = 'flags_default.png';                                                
                                                        }
                                                        else{$flags = $_language['path'];}                                                                                        
                                                    ?>
                                                    <li><?php  echo $this->Html->link($this->Html->image('/img/' .$flags), array('plugin'=>'menu','controller'=>'MenuLinks','action' => 'translate', $menu['MenuLink']['id'], $_language['code'], '?' => $_queries), array(
                                                        'class' => isset($_translateMaps[$menu['MenuLink']['id']][$_language['locale']]) ? '' : 'ui-state-disabled', 'escape' => false, 'title' => $_language['name']));?></li>           
                                                    <?php }?>
                                                </ul>
                                        <?php endif; ?>  
            							</td>
											<td>
												<ul class="wd-link-control">
													<li><a href="<?php echo $this->Html->url(array('plugin'=>'menu','controller' => 'MenuLinks', 'action' => 'edit',$menuId, $menu['MenuLink']['id'], $menu['MenuLink']['parent_id'], '?' => $_queries));?>" class="btn btn-mini"><i class="icon-edit"></i> Edit</a></li>
                                                       <?php   if ($menu['MenuLink']['custom']) {?>
					                           	       <li><a href="#<?php echo $menu['MenuLink']['id']?>" data-toggle="modal" class="btn btn-mini"><i class="icon-remove"></i> Delete</a></li>
                                                                   <?php }?>
												    <li><a href="<?php echo $this->Html->url(array('plugin'=>'menu','controller' => 'MenuLinks', 'action' => 'move', $menu['MenuLink']['id'], 'up', '?' => $_queries));?>" class="btn btn-mini"><i class="icon-arrow-up"></i> Up</a></li>
                                                    <li><a href="<?php echo $this->Html->url(array('plugin'=>'menu','controller' => 'MenuLinks', 'action' => 'move', $menu['MenuLink']['id'], 'down', '?' => $_queries));?>" class="btn btn-mini"><i class="icon-arrow-down"></i> Down</a></li>
												</ul>
											</td>
										</tr>
                         <?php endforeach?>
                    <?php foreach ($listMenuLinks as $menu) : ?>
			 	<div id="<?php echo $menu['MenuLink']['id']?>" class="modal hide">
					<div class="modal-header">
						<button data-dismiss="modal" class="close" type="button">×</button>
						<h3>Alert modal</h3>
					</div>
					<div class="modal-body">
						<p>Are you sure delete “<?php echo $menu['MenuLink']['title']?>”?</p>
					</div>
					<div class="modal-footer">
						<a data-dismiss="modal" class="btn" href="#">Cancel</a>
                        <?php echo $this->Html->link('Delete', array('plugin'=>'menu','controller' => 'MenuLinks','action' => 'delete', '?' => array_merge($_queries, array('keys' => array($menu['MenuLink']['id'])))), array('title' => false, 'class' => 'btn btn-danger','data-dismiss='=>'modal')); ?>                        
					</div>
				</div>  
    <?php endforeach?>
									</tbody>
								</table>
						
							</div>
						</div>
					</div>	
				</div>
            <?php         
            echo $this->Form->hidden('task', array('id' => 'task', 'value' => ''));
            echo $this->Form->end();?>                